﻿@using Webdiyer.WebControls.Mvc
@model PagedList<EAM.Model.AssetCategory>
@{
    ViewBag.Title = "Index";
}
@if (false)
{
    <script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
}
<div style="padding: 5px 10px;">
    <a href="@Url.Action("edit", "Category", new { cId = -1 })" class="btn_green">新建分类</a>
</div>
<div style="padding: 0px 10px;">
    <table class="tb" width="98%" style="text-align: center;">
        <tr>
            <th style="width: 20px;"></th><th valign="top">编号</th><th>资产类型名称</th><th>父类型</th><th>是否显示</th><th>开头标签</th><th>计量单位</th><th>操作</th>
        </tr>
        @foreach (var m in Model)
        {
            <tr>
                <td>
                    <input type="checkbox" name="CategoryID" value="@m.CategoryID" /></td>
                <td>@m.CategoryID</td>
                <td>@m.CategoryName</td>
                <td>
                    @( ((Dictionary<int, string>)ViewData["parentCategoryDic"])[(int)@m.CategoryParentID])
                </td>
                <td>@(@m.CategoryIsShow ? "是" : "否")</td>
                <td>@m.CategoryLabel</td>
                <td>@m.CategoryMeasure_Unit</td>
                <td width="80">
                    <a href="@Url.Action("edit", "Category", new { cid = m.CategoryID })">编辑</a>
                    <a style="display:none;" href="@Url.Action("del", "Category", new { cid = m.CategoryID })" onclick="return confirm('确认删除吗？')">删除</a>
                </td>
            </tr>
        }
        <tr>
            <td>
                <input type="checkbox" /></td>
            <td colspan="7" style="text-align: left;">
                <div style="float: left;">
                    <input type="button" value="删除" class="btn_red" onclick="deleteChooseCategory();" style="display:none;" />
                </div>
                <div style="float: right;">
                    @Html.Pager(Model)
                </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">

    function deleteChooseCategory() {
        if (!confirm('确定删除吗？')) return;
        if ($("input[name='CategoryID']:checked").length == 0) return;

        var arr = [];
        $("input[name='CategoryID']:checked").each(function () {
            arr.push($(this).val());
        });

        $.post("/Category/DeleteChoose", { ids: arr.join(',') }, function () {
            window.location = window.location;
        });
    }
</script>
